/**
 * @ClassName login
 *
 * @Author chenli
 * @Time 2018/11/19
 **/
layui.use(['layer'], function () {
    var layer = layui.layer;
    var $ = layui.jquery;

    //-----------点击登录按钮----------------
    $('#submit').click(function () {
        $.ajax({
            url: '/login/login_userLogin',
            type: 'post',
            dataType: 'json',
            data: {
                username: $('#username').val(),
                password: $('#password').val()
            },
            success: function (data) {
                if (data.status === 200) {
                    layer.msg('登录成功', {icon: 6});
                    location.href = '/show_index';
                }

            }
        });
    });

    //---------点击注册按钮----------------
    $('#register').click(function () {
        layer.open({
            type: 2,
            title: false,
            closeBtn: 0,
            area: ['516px', '500px'],
            skin: 'layui-layer-lan', //没有背景色
            shadeClose: true,
            content: ['/login/login_toRegist', 'no']
        });
    });

    //---------点击注册------------------
    $('#sign').click(function () {
        $.ajax({
            url: '/login/login_regSave',
            type: 'post',
            dataType: 'json',
            data: {
                username: $.trim($('#username').val()),
                mobile: $.trim($('#mobile').val()),
                email: $.trim($('#email').val()),
                password: $.trim($('#password').val()),
            },
            success: function (data) {
                if (data.status === 200) {
                    layer.msg('注册成功', {icon: 6});
                    parent.location.href = '/show_index';
                }
            }
        });
    });
});

